<template>
  <div class="dashboard">
    <el-card class="welcome-card">
      <div class="welcome-content">
        <h1>欢迎使用猫眼电影后台管理系统</h1>
        <p>当前时间：{{ currentTime }}</p>
        <p>欢迎您，{{ username }}</p>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useUserStore } from '@/stores/user'

const userStore = useUserStore()
const username = ref(userStore.user?.username || '管理员')
const currentTime = ref('')

// 更新当前时间
const updateTime = () => {
  const now = new Date()
  currentTime.value = now.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit',
    hour12: false
  })
}

onMounted(() => {
  updateTime()
  // 每秒更新一次时间
  setInterval(updateTime, 1000)
})
</script>

<style scoped>
.dashboard {
  height: 100%;
  overflow: hidden;
  background-color: #f5f7fa;
}

.welcome-card {
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

.welcome-content {
  text-align: center;
}

.welcome-content h1 {
  color: #409EFF;
  margin-bottom: 30px;
  font-size: 32px;
}

.welcome-content p {
  color: #666;
  font-size: 18px;
  line-height: 2;
  margin: 15px 0;
}
</style> 